﻿<controlBase:ControlBase x:Name="uPrintArea" 
    x:Class="Rio.Framework.Pages.Controls.PrintAreaControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Rio.Framework.Pages.UserControls"
    xmlns:Vignette="clr-namespace:Rio.Framework.Pages.Viewer;assembly=Rio.Framework.Pages"
    xmlns:Converter="clr-namespace:Rio.Framework.Pages.Helpers"
    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:ToolKit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:dragDrop="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:RioCommonControls="clr-namespace:Rio.Framework.Pages.Controls;assembly=Rio.Framework.Pages"
    xmlns:controlBase="clr-namespace:Rio.Framework.Pages"
    mc:Ignorable="d"
    d:DesignHeight="150" d:DesignWidth="600" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <controlBase:ControlBase.Resources>
        <Converter:ByteArrayToBitmapImageConverter x:Key="ByteArrayToBitmapImageConverter" />
        <Style TargetType="ListBoxItem"
               x:Key="draggableListBoxItem">
            <Setter Property="dragDrop:RadDragAndDropManager.AllowDrag"
                    Value="True" />
            <Setter Property="dragDrop:RadDragAndDropManager.AllowDrop"
                    Value="True" />
            <Setter Property="HorizontalAlignment"
                    Value="Center" />
            <Setter Property="VerticalAlignment"
                    Value="Center" />
        </Style>

        <Style x:Key="WrapPanelStyle"
               TargetType="ToolKit:WrapPanel">
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1"
                                         StartPoint="0.5,0">
                        <GradientStop Color="#CF484848"
                                      Offset="0" />
                        <GradientStop Color="#DBADADAD"
                                      Offset="1" />
                        <GradientStop Color="#ADA7A7A7"
                                      Offset="0.401" />
                        <GradientStop Color="#F3AAAAAA"
                                      Offset="0.709" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="ListBox"
               x:Key="draggableListBox">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBox">
                        <Border x:Name="ListBoxBorder"
                                CornerRadius="2"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="DragCue">
                                    <vsm:VisualState x:Name="NoDrop" />
                                    <vsm:VisualState x:Name="DropPossible">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DropCueElement"
                                                                           Storyboard.TargetProperty="(UIElement.Visibility)">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                                        Value="Visible" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ListBoxBorder"
                                                                           Storyboard.TargetProperty="(Border.BorderBrush)">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                                        Value="Orange" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="DropImpossible" />
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <ScrollViewer Padding="{TemplateBinding Padding}"
                                          Background="{TemplateBinding Background}"
                                          BorderBrush="Transparent"
                                          BorderThickness="0">
                                <Grid>
                                    <ItemsPresenter />
                                    <Grid x:Name="DropCueElement"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Top"
                                          IsHitTestVisible="False"
                                          Margin="0,5,0,0"
                                          dragDrop:RadDragAndDropManager.AllowDrop="True"
                                          Visibility="Collapsed">
                                        <Rectangle Width="5"
                                                   Height="100"
                                                   HorizontalAlignment="Center"
                                                   IsHitTestVisible="False"
                                                   Fill="LightGreen" />
                                    </Grid>
                                </Grid>
                            </ScrollViewer>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemContainerStyle"
                    Value="{StaticResource draggableListBoxItem}" />
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <ToolKit:WrapPanel Style="{StaticResource WrapPanelStyle}" />
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Border BorderBrush="{Binding IsFullSearch}"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center">
                            <local:Thumbnail Title="{Binding OriginalName}"
                                             Icon="{Binding OriginalName}"
                                             ImageSource="{Binding Img, Converter={StaticResource ByteArrayToBitmapImageConverter}}"
                                             NumberPages="{Binding NumberPages}"
                                             IsCutedOrCopied="{Binding IsCutedOrCopied}"
                                             IsFulltext="{Binding IsFullSearch}"
                                             Width="100"
                                             Height="100">
                                <ToolTipService.ToolTip>
                                    <ToolTip>
                                        <TextBlock Name="NameVignette"
                                                   Text="{Binding OriginalName}"
                                                   TextWrapping="Wrap"
                                                   VerticalAlignment="Center"
                                                   HorizontalAlignment="Left" />
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </local:Thumbnail>
                        </Border>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="GridStyle" TargetType="Grid">
        	<Setter Property="Background">
        		<Setter.Value>
        			<LinearGradientBrush EndPoint="300,150" MappingMode="Absolute" StartPoint="300,0" SpreadMethod="Reflect" Opacity="0.5">
        				<GradientStop Color="#FF463C3C" Offset="0"/>
        				<GradientStop Color="#FFAFBCB9" Offset="0.635"/>
        			</LinearGradientBrush>
        		</Setter.Value>
        	</Setter>
        </Style>

    </controlBase:ControlBase.Resources>


    <Grid x:Name="LayoutRoot" Style="{StaticResource GridStyle}">
        
        <Grid.RowDefinitions>
            <RowDefinition MaxHeight="40"  />
            <RowDefinition Height="*"/>
            
        </Grid.RowDefinitions>
        <telerikNavigation:RadToolBar Grid.Row="0" FlowDirection="RightToLeft" Width="150" HorizontalAlignment="Right">
            <telerik:RadButton Margin="2" Click="Print_Click">
                <Image Source="/Rio.Framework.Pages;component/Assets/Images/Viewer/Printer.png" Stretch="UniformToFill" ToolTipService.ToolTip="Imprimer"/>
            </telerik:RadButton>
            <telerik:RadButton Margin="2" Click="Delete_Click">
                <Image Source="/Rio.Framework.Pages;component/Assets/Images/Delete.png" Stretch="UniformToFill" ToolTipService.ToolTip="Supprimer" />
            </telerik:RadButton>
            <telerik:RadButton Margin="2" Click="Add_Click">
                <Image Source="/Rio.Framework.Pages;component/Assets/Images/AddControl.png" Stretch="UniformToFill" ToolTipService.ToolTip="Ajouter"/>
            </telerik:RadButton>
            


        </telerikNavigation:RadToolBar>
        <ListBox  Name="ListBoxVignette"
                  Style="{StaticResource draggableListBox}"
                  Grid.Row="1"
                  Grid.Column="0"
                  Grid.ColumnSpan="3"
                  HorizontalContentAlignment="Center"
                  SelectionMode="Extended"
                  ItemsSource="{Binding ListItemSource, ElementName=uPrintArea, Mode=TwoWay}"
                  />
    </Grid>
</controlBase:ControlBase>
